diff --git a/astropy/utils/masked/core.py b/astropy/utils/masked/core.py
index 8a634cb148..f299df0290 100644
--- a/astropy/utils/masked/core.py
+++ b/astropy/utils/masked/core.py
@@ -693,13 +693,17 @@ class MaskedNDArray(Masked, np.ndarray, base_cls=np.ndarray, data_cls=np.ndarray
         out_mask = None
         if out is not None:
             out_unmasked, out_masks = self._get_data_and_masks(*out)
-            for d, m in zip(out_unmasked, out_masks):
-                if m is None:
-                    # TODO: allow writing to unmasked output if nothing is masked?
-                    if d is not None:
-                        raise TypeError("cannot write to unmasked output")
-                elif out_mask is None:
-                    out_mask = m
+            if any(masks):
+                for d, m in zip(out_unmasked, out_masks):
+                    if m is None:
+                        # If any input is masked, we cannot write to an unmasked output
+                        if d is not None:
+                            raise TypeError("cannot write to unmasked output")
+                    elif out_mask is None:
+                        out_mask = m
+            else:
+                # If no inputs are masked, allow writing to unmasked output
+                out_mask = np.zeros_like(out_unmasked[0], dtype=bool)
 
         unmasked, masks = self._get_data_and_masks(*inputs)
 
